<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>022-面向对象-继承四.html</title>
	<script>
		function Person(name,age){
		console.log(1);
		this.name = name;
		this.age = age;
	}
	Person.prototype.showName = function(){
		console.log('I am '+ this.name);
	}
	Object.defineProperty(Person.prototype,"showAge",{
		value:function(){
			console.log("I am "+ this.age + 'years old');
		},
		enumerable:false
	}) 
	Person.prototype.LEGS = 2;

	function Student(name,age,major){
		Person.call(this,name,age);
		this.major = major;
	}
	// var obj = Object.create(Person.prototype);
	// console.log(obj);
	
	Student.prototype = Object.create(Person.prototype);
	Student.prototype.constructor = Student;
	console.log(Student.prototype);
	Student.prototype.showMajor = function(){
		console.log("I am from "+this.major);
	}
	var s1 = new Student("Chris",18,"COM");
		console.log(s1);
		s1.showName();
		s1.showAge();
		s1.showMajor();


	var p1 = new Person("Vincent",24);
		// console.log(p1);
		p1.showName();
		p1.showAge();
		// p1.showMajor();
	</script>
</head>
<body>
	
</body>
</html>